﻿package ui;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.rmi.RemoteException;

import generalManagerLogic.MockGeneralManagerLogic;

import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;

import main.Main;
import vo.generalManager.GivePanelVO;
import vo.generalManager.LoginPanelVO;

import components.MyButton;
import components.MyFrame;
import components.MyPanel;


public class GivePanel extends MyPanel {

	private MyButton logoutButton;
	private MyButton returnbackButton;
	
	private JLabel dJJgivenNumLabel;
	private JLabel dZJgivenNumLabel;
	private JTextField DJJgivenNumfield;
	private JTextField DZJgivenNumfield;
	private MyButton givenButton;
	private JTextField DJJgivenSizefield;
	private JTextField DZJgivenSizefield;

	protected void initComponent() {
		logoutButton = new MyButton("注销");
		returnbackButton = new MyButton("返回");
		logoutButton.setBounds(MyFrame.WIDTH-80,0, 80, 20);
		returnbackButton.setBounds(MyFrame.WIDTH-160,0, 80, 20);
		this.add(logoutButton);
		this.add(returnbackButton);
		
		this.setBounds(400, 200, 400, 300);
		dJJgivenNumLabel = new JLabel("等价劵： /元 /张");
		dZJgivenNumLabel = new JLabel("打折卷： /% /张");
		DJJgivenNumfield = new JTextField();
		DZJgivenNumfield = new JTextField();
		DJJgivenSizefield = new JTextField();
		DZJgivenSizefield = new JTextField();
		givenButton = new MyButton("赠送");
		dJJgivenNumLabel.setBounds(30, 30, 120, 20);
		dZJgivenNumLabel.setBounds(30, 60, 120, 20);
		DJJgivenNumfield.setBounds(260, 30, 60, 25);
		DZJgivenNumfield.setBounds(260, 60, 60, 25);
		DJJgivenSizefield.setBounds(180, 30, 60, 25);
		DZJgivenSizefield.setBounds(180, 60, 60, 25);
		givenButton.setBounds(160, 160, 60, 30);
		this.add(dJJgivenNumLabel);
		this.add(dZJgivenNumLabel);
		this.add(DJJgivenNumfield);
		this.add(DZJgivenNumfield);
		this.add(DJJgivenSizefield);
		this.add(DZJgivenSizefield);
		this.add(givenButton);
		
		logoutButton.setButtonAction("logout");
		returnbackButton.setButtonAction("toTicket");
		givenButton.setButtonAction("give");
	}

	protected void updateVO() {
		GivePanelVO gpvo=null;
		try {
			gpvo = Main.getLogic().getGpvo();
		} catch (RemoteException e) {
			e.printStackTrace();
		}
		gpvo.setDJJgivenNum(DJJgivenNumfield.getText());
		gpvo.setDJJgivenSize(DJJgivenSizefield.getText());
		gpvo.setDZJgivenNum(DZJgivenNumfield.getText());
		gpvo.setDZJgivenSize(DZJgivenSizefield.getText());
		try {
			Main.getLogic().setGpvo(gpvo);
		} catch (RemoteException e) {
			e.printStackTrace();
		}
	}


}
